package com.sk.skplanet.commute.views;

import java.io.File;

import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.view.Menu;

import com.sk.skplanet.commute.R;
import com.sk.skplanet.commute.vo.Data;

@SuppressLint("HandlerLeak")
public class SplashActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splashactivity);
		
		ActionBar actionBar = getActionBar();
		actionBar.hide();
		
		Handler handler = new Handler() {
			@Override
			public void handleMessage(Message msg) {

				Intent i = new Intent(SplashActivity.this, RouteList.class);
				File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + Data.FilePATH);
				if (!dir.exists()) dir.mkdirs();
				//File target = new File(dir.getAbsolutePath() + Data.FileNAME);
//				if (!target.exists()) {
//					startActivity(i);
//					finish();
//				} else {// Local DB
//						// new LocalDaoFactory();
//					String authKey = new SQLiteTask().getAuthKey();
//					// authKey = "";
//					// Log.i("key", "" + authKey);
//					if ("".equals(authKey) || authKey == null) {
//						startActivity(i);
//						finish();
//					} else {
//						new LoadingTask(SplashActivity.this, authKey).execute();
//					}
//				}
				
				startActivity(i);
				finish();
			}
		};
		handler.sendEmptyMessageDelayed(0, Data.splashTime);

	}
}
